#include<iostream>
using namespace std;
typedef unsigned long long ULL;
ULL a, b;
int main()
{
	cin >> a >> b;
	ULL ans = 0;
	while (b) {
		if (b & 1) {
			ans += a;
		}
		a = a * 2;
		b >>= 1;
	}
	cout << ans << endl;
	return 0;
}